﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Dal
{
    public class RecommendPro
    {
        public static DataTable MULTIPLE(string strCon,string whereStr) 
        {
            DataTable dt = new DataTable();
            SqlParameter[] par = { new SqlParameter("@WhereStr", whereStr) };
            try
            {
                dt = SqlHelper.ExecuteDataTable(Public.DataProtector.DecryptString(strCon), CommandType.StoredProcedure, "SP_TRecommendPro_MULTIPLE", par);
            }
            catch (Exception)
            { 
                throw;
            }
            return dt;
        }

        public static int INSERT(string strCon,DateTime startDate,DateTime endDate) 
        {
            int rtn = 0;
            SqlParameter[] pars = { 
                                    new SqlParameter("@StartDate",startDate),
                                    new SqlParameter("@EndDate",endDate)
                                  };  
            try
            {
                rtn = SqlHelper.ExecuteNonQuery(Public.DataProtector.DecryptString(strCon), CommandType.StoredProcedure, "SP_TRecommendPro_INSERT", pars);
            }
            catch (Exception)
            {
                throw;
            }
            return rtn;
        }

        public static DataTable Single(string strCon,int proId) 
        {
            DataTable dt = new DataTable();
            SqlParameter[] par = { new SqlParameter("@ProId", proId) };
            try
            {
                dt = SqlHelper.ExecuteDataTable(Public.DataProtector.DecryptString(strCon), CommandType.StoredProcedure, "SP_TRecommendPro_SINGLE", par);
            }
            catch (Exception)
            {
                throw;
            }
            return dt;
        }

        public static int Update(string strCon,int proId,DateTime startDate,DateTime endDate,int valid) 
        {
            int rtn = 0;
            SqlParameter[] par = { 
                                    new SqlParameter("@ProId", proId),
                                    new SqlParameter("@StartDate",startDate),
                                    new SqlParameter("@EndDate",endDate),
                                    new SqlParameter("@Valid",valid)
                                 };
            try
            {
                rtn = SqlHelper.ExecuteNonQuery(Public.DataProtector.DecryptString(strCon), CommandType.StoredProcedure, "SP_TRecommendPro_UPDATE", par);
            }
            catch (Exception)
            {
                throw;
            }
            return rtn;
        }

    }
}
